﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.Practices.Prism.ViewModel;
using BBInterfaceNET.CommonServices;

namespace BBInterfaceNET.Designer.ViewModels
{
    public class AddFieldViewModel:NotificationObject
    {
        private ToolboxItem selItem;
        private List<ToolboxItem> items;
        private IToolboxService toolboxService;

        public AddFieldViewModel(IToolboxService toolboxService)
        {
            this.toolboxService = toolboxService;
        }

        public List<ToolboxItem> Items
        {
            get
            {
                if (items == null)
                    items = toolboxService.GetItems();
                return items;
            }
        }
        public ToolboxItem SelectedItem
        {
            get 
            {
                if (selItem == null) selItem = Items.FirstOrDefault();
                return selItem; 
            }
            set
            {
                if (selItem != value)
                {
                    selItem = value;
                    RaisePropertyChanged(() => SelectedItem);
                }
            }
        }
    }
}
